<?php
namespace Terrafirma\Predicate\Composite;

use SplObjectStorage;
use Terrafirma\Predicate\PredicateInterface;

class OrPredicate implements PredicateInterface
{
	protected $predicates;
	
	public function __construct()
	{
		$this->predicates = new SplObjectStorage();
		foreach(func_get_args() as $predicate) {
			$this->predicates->attach($predicate);
		}
	}
	public function evaluate($input)
	{
		foreach($this->predicates as $predicate) {
			if($predicate->evaluate($input)) {
				return true;
			}
		}
		return false;
	}
}